home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / stik_dev / forecast / complete.s < prev    next >
Text File  |  1995-10-20  |  2KB  |  119 lines

  1.  
  2.     SECTION TEXT,CODE
  3.  
  4.     XDEF    _test_point,_get_point,_clear_mfdb,_move_mfdb
  5.  
  6. _test_point:
  7.     movea.l    4(sp),a0    ; Pointer to MFDB
  8.     move.w    8(sp),d1    ; Word x offset
  9.     move.w    10(sp),d0    ; Word y offset
  10.     movea.l    (a0),a1        ; .fd_addr
  11.     move.w    8(a0),d2    ; .fd_wdwidth
  12.     ext.l    d0
  13.     ext.l    d1
  14.     ext.l    d2
  15.     lsl        #1,d2
  16.     muls.l    d2,d0
  17.     move.l    d1,d2
  18.     lsr        #3,d2
  19.     add.l    d2,d0
  20.     adda.l    d0,a1        ; 2*wordwidth*y+x>>3 = byte offset into memory
  21.     lsl        #3,d2
  22.     sub.l    d2,d1        ; x-(x>>3)<<3 = bit offset into memory
  23.     clr.l    d0
  24.     clr.l    d2
  25.     move.b    (a1),d2
  26.     btst    d1,d2
  27.     sne        d0            ; If Z is set, then bit is zero
  28.     rts
  29.  
  30. _get_point:
  31.     movea.l    4(sp),a0    ; pointer to MFDB
  32.     movea.l    (a0),a1        ; .fd_addr
  33.     move.w    6(a0),d1    ; .fd_height
  34.     move.w    8(a0),d2    ; .fd_wdwidth
  35.     movea.l    a1,a0
  36.     muls    d2,d1
  37.     ext.l    d2
  38.     lsl.l    #1,d2
  39. G1:    subq.l    #2,d1
  40.     bmi.s    G4
  41.     move.l    (a1)+,d0
  42.     tst.l    d0
  43.     beq.s    G1
  44.     suba.l    #4,a1
  45. G2:    move.b    (a1)+,d0
  46.     tst.b    d0
  47.     beq.s    G2
  48.     suba.l    #1,a1
  49.     move.l    a1,d1
  50.     sub.l    a0,d1
  51.     divs    d2,d1
  52.     swap    d1
  53.     lsl.w    #3,d1
  54.     subq.w    #1,d1
  55. G3:    addq.w    #1,d1
  56.     lsl.b    #1,d0
  57.     bcc.s    G3
  58.     move.l    d1,d0
  59.     rts
  60. G4:    addq.l    #1,d1
  61.     bne.s    G5
  62.     move.w    (a1),d0
  63.     tst.w    d0
  64.     bne.s    G2
  65. G5:    moveq.l    #-1,d0
  66.     rts
  67.  
  68. _clear_mfdb:
  69.     movea.l    4(sp),a0            ; pointer to MFDB
  70.     move.w    12(a0),d0            ; .fd_height
  71.     muls    8(a0),d0            ; .fd_wdwidth
  72.     muls    6(a0),d0            ; .fd_nplanes
  73.     movea.l    (a0),a0                ; .fd_addr
  74.     movem.l    d1-d7/a1,-(sp)
  75.     moveq.l #0,d1
  76.     moveq.l    #0,d2
  77.     moveq.l    #0,d3
  78.     moveq.l    #0,d4
  79.     moveq.l    #0,d5
  80.     moveq.l    #0,d6
  81.     moveq.l    #0,d7
  82.     movea.l    d1,a1
  83. Z1:    subi.l    #16,d0
  84.     bmi.s    Z2
  85.     movem.l    d1-d7/a1,(a0)        ; Push zeros to address
  86.     lea        32(a0),a0
  87.     bra.s    Z1                    ; Go until the 16words are gone
  88. Z2:    addi.l    #16,d0
  89.     andi.l    #$F,d0
  90.     subq.l    #1,d0
  91.     bmi.s    ZE
  92. Z3:    move.w    d1,(a0)+
  93.     dbra    d0,Z3
  94. ZE:    movem.l    (sp)+,d1-d7/a1
  95.     rts
  96.  
  97. _move_mfdb:
  98.     movea.l    4(sp),a0
  99.     movea.l    8(sp),a1
  100.     move.w    12(a0),d0
  101.     muls    8(a0),d0
  102.     muls    6(a0),d0
  103.     movea.l    (a0),a0
  104.     movea.l    (a1),a1
  105.     movem.l    d1-d7/a2,-(sp)
  106. M1:    subi.l    #16,d0
  107.     bmi.s    M2
  108.     movem.l    (a0)+,d1-d7/a2        ; Push zeros to address
  109.     movem.l    d1-d7/a2,(a1)
  110.     lea        32(a1),a1
  111.     bra.s    M1                    ; Go until the 16words are gone
  112. M2:    addi.l    #16,d0
  113.     subq.l    #1,d0
  114.     bmi.s    ME
  115. M3:    move.w    (a0)+,(a1)+
  116.     dbra    d0,M3
  117. ME:    movem.l    (sp)+,d1-d7/a2
  118.     rts
  119.     END